<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="../js/vue.min.js"></script>
    <script src="../js/vue-router.js"></script>
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <router-link to="/a">路径a</router-link>
      <!-- 别名访问 -->
      <router-link to="/user">别名访问</router-link>
      <!-- 路由路径重定向 -->
      <router-link to="/b">路径b</router-link>
      <!-- 路由名字重定向 -->
      <router-link to="/c">路径c</router-link>
      <router-view></router-view>
    </div>
    <script>
      // 模板一
      const t1 = {
        template: `<div style="width:400px;height:200px;border:blue 1px solid">index</div>`,
      };

      // 配置路由
      const router = new VueRouter({
        routes: [
          {
            path: "/a",
            name: "r1",
            alias: "/user",
            component: t1,
          },
          {
            path: "/b",
            redirect: "/a",
          },
          {
            path: "/c",
            redirect: { name: "r1" },
          },
        ],
      });
      var vue = new Vue({
        el: "#app",
        router: router,
      });
    </script>
  </body>
</html>
